#!/bin/sh

# Create initramfs.cpio.gz
# Author: Julien Chauveau <julien.chauveau@neo-technologies.fr>

# Usage: mkcpiogz <directory>

if [ $# != 1 ] || [ ! -d $1 ]; then
  echo "Usage: ${0##*/} <directory>" ; exit 1
fi

cd $1
DIR=$(pwd)
IMG=$DIR.cpio.gz

sudo sh -c "find . | cpio -H newc -o | gzip -9 > $IMG"

echo "Archive created: $IMG"
